<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 数据表格</title>
<#include "../comm/commcss/commCss.ftl">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>基本
                        <small>数据表列表</small>
                    </h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="table_data_tables.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="table_data_tables.html#">选项1</a>
                            </li>
                            <li><a href="${base}/city/add.show">新增</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <button class="btn btn-success btn-batchCreate" type="button">
                        <i class="fa fa-upload"></i>&nbsp;&nbsp;<span class="bold">批量生成code</span>
                    </button>
                    <button class="btn btn-success btn-batchqiang" type="button">
                        <i class="fa fa-upload"></i>&nbsp;&nbsp;<span class="bold">抢</span>
                    </button>
                    <table class="table table-striped table-bordered table-hover dataTables-tableList"
                           id="dataTables-tableList">
                        <thead>
                        <tr>
                            <th><a href="#" class="check-link" id="selectAll_checkbox">
                                <i class="fa fa-square-o"></i> 全选</a></th>
                            <th>表名</th>
                            <th>引擎</th>
                            <th>描述</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list showTablesList as map>
                        <tr class="gradeA">
                            <td>
                                <a href="#" class="check-link" data-tableName="${map['tableName']?default("")}">
                                    <i class="fa fa-square-o"></i>
                                </a>
                            </td>
                            <td>${map['tableName']?default("")}</td>
                            <td>${map['engine']?default("")}</td>
                            <td>${map['tableComment']?default("")}</td>
                            <td>${map['createTime']?default("")}</td>
                        <#-- <#list map?keys as itemKey>-->
                        <#-- key:${itemKey}----value:-->
                        <#-- <#if itemKey="tableName">
                             Phone:
                         </#if>
                         <#if itemKey="email">
                             Email:${map[itemKey]}
                         </#if>-->
                        <#--</#list>-->
                            <td>
                                <div class="text-center">
                                    <button type="button" class="btn btn-primary" data-toggle="modal"
                                            data-target="#myModal5">
                                        生成code
                                    </button>
                                </div>
                            </td>
                        </tr>
                        </#list>
                        </tbody>
                        <tfoot>
                        <tr>
                            <th></th>
                            <th>表名</th>
                            <th>引擎</th>
                            <th>描述</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<#include "${base}/comm/commjs/commJs.ftl">
<!-- 自定义js -->
<script src="${base}/js/content.js?v=1.0.0"></script>
<!-- Sweet alert -->
<script src="${base_oss}/js/plugins/sweetalert/sweetalert.min.js"></script>
<script>
    $(document).ready(function () {
        $('.btn-batchCreate').click(function () {
            var tableNames = tablesUtils.getSelectTablesName();
            var data = {
                tableNames: tableNames
            }
            console.log(data);
            tablesUtils.createCodeZip(tableNames);
        });
        $('.btn-batchqiang').click(function () {
            console.log("点击数");
            $.post("${base}/sycn/sycn.do",{id:1,status:2},function (result){
                console.log("点击结果1"+result.success);
            });
           /* $.post("${base}/sycn/sycn.do",{id:'1',status:'2'},function (result){
                console.log("点击结果2"+result.success);
            });
*/
        });
        $('#selectAll_checkbox').click(function () {
//
            var $childNode = $(this).find("i");

            if ($childNode.attr("class") == 'fa fa-check-square') {
                tablesUtils.checkAllBox('fa fa-check-square');
            } else {
                tablesUtils.checkAllBox('fa fa-square-o');
            }

        });

    });
    (function () {
        function tablesUtils() {
            var createCodeZip = function (data) {
                location.href="/sys/saveZip.do?tableNames="+data;
            }
            var checkAllBox = function (classattr) {
                $(".check-link").each(function (index) {
                    if (index != 0) {
                        $(this).find("i").removeAttr("class").attr("class", classattr)
                    }
                });
            }
            var getSelectTablesName = function () {
                var tablesName =  new Array()
                var num = 0;
                $(".check-link").each(function (index) {
                    if (index != 0) {
                        var className = $(this).find("i").attr("class")
                        if (className == 'fa fa-check-square') {
                            tablesName.push($(this).data('tablename'));
                            num++;
                        }
                    }
                });
                return tablesName;
            }

            return {
                createCodeZip: createCodeZip,
                checkAllBox: checkAllBox,
                getSelectTablesName: getSelectTablesName
            };
        }

        window.tablesUtils = tablesUtils();
    })();


</script>
</html>
